﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using EntityObject;
using System.Data.SqlClient;
using System.Data;
using SharedLibraries;
using ThangNM_LIB.FUNC;

namespace DataAccessObject
{
    public class TempDAO : DB_SQL_EXT
    {

        public Boolean Update(TempEO _TempEO)
        {
            SqlCommand cmd = new SqlCommand("Temp_Insert_Update");
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@PK_iTempID", _TempEO.PK_iTempID));
            cmd.Parameters.Add(new SqlParameter("@sContent", _TempEO.sContent));
            return ExecuteNonQuery_RetBool(cmd);
        }

        public TempEO SelectItem(Int16 _PK_iTempID)
        {
            SqlCommand cmd = new SqlCommand("Temp_SelectItem");
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@PK_iTempID", _PK_iTempID));
            return TempDO(GetDataTable(cmd));
        }

        public TempEO TempDO(DataTable input)
        {
            List<TempEO> lst = new List<TempEO>();
            lst = (List<TempEO>)ConvertEx.ConvertDataTableToListObject<TempEO>(input, lst.GetType());
            if (CommonsCheck.ListObject_OK(lst))
                return lst[0];
            else
                return null;
        }

    }
}